#ifndef MOTOR_H_
#define MOTOR_H_

#include "../hardware.h"

/**
 * Using the same PORT and DDR as SERVO
 **/
#define MOTOR_PORT ((byte) 6)
/** 
 * The null position for the motor. No movement.
 **/
#define MOTOR_NULL  ((byte) 170)
/**
 * The maximum possible speed for the motor backward.
 **/
#define MOTOR_FULL_BACKWARDS ((byte) 124)
/**
 * The maximum possible speed for the motor forward.
 **/
#define MOTOR_FULL_FORWARDS ((byte) 215)
/**
 * The minimum speed required for the motion backward.
 **/
#define MOTOR_MIN_BACKWARDS ((byte) 148)
/**
 * The minimum speed required for the motion forward.
 **/
#define MOTOR_MIN_FORWARDS ((byte) 194)
/**
 * Sets output low for Motor
 **/
#define MOTOR_LOW SERVO_PORT &= ~(1<<MOTOR_PORT)
/**
 * Sets output high for Motor
 **/
#define MOTOR_HIGH SERVO_PORT |= (1<<MOTOR_PORT)

byte old_spd;

extern void set_motor_speed(byte spd);

extern void stop_motor();

extern byte brake(byte old, byte new);

#endif /* MOTOR_H_ */
